/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2022-12-06 09:57:11
 * @LastEditTime: 2022-12-06 11:48:51
 * @LastEditors: 赵大壮
 */
import nyNetwork from "@/api/nyBaseNetwork";
import DZModelPage from "@/model/DZModelPage";
import nyMessageToast from "@/utils/NYMessageToast";
import DZModelUserAssess from "../model/DZModelUserAssess";

class DZServiceUserAssess {

    m_page = new DZModelPage(10);

    list_user_assess: Array<DZModelUserAssess> = [];

    m_screen = {
        assessId: null,
        status: null,
        time: null,
        orderNum: null,
        name: null
    }

    net_list_user_assess() {
        var arr_data = [];
        nyNetwork.net("用户测评列表", { ...this.m_page, ...this.m_screen, time: this.m_screen.time ? this.m_screen.time / 1000 : null }, data => {
            this.m_page.total = data.total;
            for (const item of data.list) {
                var model = new DZModelUserAssess();
                model.assess = item.sassessName ?? '';
                model.name = item.sname ?? '';
                model.phone = item.sphone ?? '';
                model.email = item.semail ?? '';
                model.status = item.ireportStatus ?? null;
                model.path = item.sreportPdfPath ?? '';
                arr_data.push(model);
            }
            this.list_user_assess = arr_data;
        })
    }

    net_down_load(path) {
        nyNetwork.download("下载文件", "?path=" + encodeURIComponent(path));
    }

    net_export_data() {
        if (!this.m_screen.assessId) {
            nyMessageToast.error("请选择量表");
            return;
        }
        if (!this.m_screen.time) {
            nyMessageToast.error("请选择日期");
            return;
        }
        nyNetwork.downFile("导出测评列表", { assessId: this.m_screen.assessId, time: this.m_screen.time / 1000 }, "测评记录.xlsx");
    }

}
export default DZServiceUserAssess;